import { useState, useEffect, useDebugValue } from "react";

const useDjs = () => {
  useDebugValue("useDjs");

  const [sec, setSec] = useState(3);
  useEffect(() => {
    let timer = setTimeout(() => {
      console.log(sec);
      if (sec > 0) {
        setSec((v) => v - 1);
      } else {
        clearInterval(timer);
        timer = null;
      }
    }, 1000);
  }, [sec]);

  return sec;
};

export default useDjs;
